﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="create-signature.aspx.cs" Inherits="famails.BackEnd.page.create_signature" MasterPageFile="~/Master.Master" %>

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">

<div style="width:100%;padding:10px;">
        <!--start content 01-->
    <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;border:1px solid #333;margin-bottom:10px;">
        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:10px 20px;background:#000;color:#fff;font-size:18px;font-weight:bold;position:relative;">   
            Tạo chữ ký
        </div>
			    
		<div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;">
		   <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:10px;">
		    <asp:Panel Visible="false" ID="pnError" runat="server">
            <div class="error-box round">
                <asp:Label ID="lblError"  runat="server" Text=""></asp:Label> 
            </div>
            </asp:Panel>
            <asp:Panel Visible="false" ID="pnSuccess" runat="server">
            <div class="confirmation-box round">
                <asp:Label ID="lblSuccess"  runat="server" Text=""></asp:Label> 
            </div>
            </asp:Panel>
            </div>
			<div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding:0px;" id="tblList">
			                				  
        		<asp:HiddenField ID="hdfId" runat="server" />       				
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:10px;">
                    <fieldset>
                        <p>
                            <label for="simple-input" style="font-weight: bolder; text-transform: none">
                                Tên chữ ký </label>
                                <asp:TextBox ID="txtSignatureName" CssClass="form-control" style="border:1px solid #333;border-radius:0px;"
                                                runat="server"></asp:TextBox><br>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                                            ControlToValidate="txtSignatureName" Display="Dynamic" ErrorMessage="Vui lòng nhập vào tên chữ ký !" 
                                                                            ValidationGroup="Check_Input_Insert"></asp:RequiredFieldValidator>
                        </p>
                    </fieldset>
                </div>   
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:10px;">
                    <fieldset>
                        <p>
                            <label for="simple-input" style="font-weight: bolder; text-transform: none">
                                Nội dung chữ ký </label>
                                <CKEditor:CKEditorControl ID="txtBody" runat="server" CausesValidation="True" ResizeEnabled="False"></CKEditor:CKEditorControl>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                                            ControlToValidate="txtBody" Display="Dynamic" ErrorMessage="Vui lòng nhập vào nội dung chữ ký !" 
                                                                            ValidationGroup="Check_Input_Insert"></asp:RequiredFieldValidator>
                        </p>
                    </fieldset>
                </div>
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:10px;padding-top:0px;">
                    <button ValidationGroup="Check_Input_Insert" runat="server" class="btn" style="background:#333;color:#fff;text-align:center;padding:6px 15px;border-radius:0px;" onserverclick="btnSaveContent_Click">
                        <i class="fa fa-save"></i> Lưu
                    </button>
                </div>
        <style>
                    #contentjqxgrid {
                        width:100% !important;
                    }
                    #pagerjqxgrid {
                        width:100% !important;
                    }
                    #contentjqxgrid_error{
                        width:100% !important;
                    }
                    #pagerjqxgrid_error{
                        width:100% !important;
                    }
        </style>
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto;padding:0px;">
			<%--	<table>	                
			<asp:DataList ID="dlSignature" runat="server" 
                    RepeatColumns="1"  Width="100%">  
                    <HeaderTemplate>
                        <thead>            					
		                    <tr>
			                    <th>No.</th>
			                    <th>Tên chữ ký</th>			                           
			                    <th>Thao tác</th>
		                    </tr>            						
	                    </thead>
                    </HeaderTemplate>                      
                    <ItemTemplate>                                      						
						    <tbody>
							    <tr>
							        <td>								            
                                        <asp:Label ID="lblNo" runat="server" Text="ConfigId"></asp:Label>
								    </td>
								    <td>								            
                                        <asp:LinkButton ID="lbtSubject" runat="server" Width="200px"></asp:LinkButton>
								    </td>                                            			            
								    <td>
           
								        <asp:LinkButton ID="lbtEdit" runat="server" Height="15px" 
                                                Width="15px" onclick="lbtEdit_Click"></asp:LinkButton>
								        <asp:LinkButton ID="lbtDelete" runat="server" Height="15px" 
								        OnClientClick="return confirmDelete('Nếu tiếp tục dữ liệu sẽ bị xóa khỏi hệ thống ?')"
                                            Width="15px" onclick="lbtDelete_Click"></asp:LinkButton>
     
								    </td>
								            
							    </tr>             						
						    </tbody>         
                             
                    </ItemTemplate>
                    <FooterTemplate>
                    <tfoot>
					    <tr>
						    <td colspan="5" class="table-footer">
						    </td>
					    </tr>
				    </tfoot>                     
                    </FooterTemplate>
                </asp:DataList>
            </table>--%>

                        <div id='jqxWidget' style="width:100%;font-size: 13px; font-family: Verdana; float: left;">
                            <div id="jqxgrid" style="width:100% !important;">
                            </div>
                            <div id="paginginfo">
                            </div>
                            <div id="popupWindow">
                                <div>
                                    Xóa Broadcasting
                                </div>
                                <div style="overflow: hidden;">
                                    <p>
                                        Bạn có chắc là muốn xóa chữ ký này không?
                                    </p>
                                    <button id="del">
                                        Yes</button>
                                    <button id="cancel">
                                        No</button>
                                </div>
                            </div>
                        </div>
        <!----------------->
                <script type="text/javascript">
                    function getQueryStrings() {
                        var assoc = {};
                        var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
                        var queryString = location.search.substring(1);
                        var keyValues = queryString.split('&');

                        for (var i in keyValues) {
                            var key = keyValues[i].split('=');
                            if (key.length > 1) {
                                assoc[decode(key[0])] = decode(key[1]);
                            }
                        }

                        return assoc;
                    }
                    jQuery(function ($) {
                        var qs = getQueryStrings();
                        var id = qs["id"];
                        //alert(id);
                        var cellsrenderer = function (row, column, value) {
                            var id = $("#jqxgrid").jqxGrid('getcellvalue', row, "id");
                            //alert(name);
                            return '<a style="margin: 4px;color:#000;" href="create-signature.aspx?id=' + id + '">' + value + '</a>';
                        }
                        $("#jqxgrid").jqxGrid('showloadelement');
                        $.ajax({
                            type: "POST",
                            url: "create-signature.aspx/search",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                var source =
                        {
                            datatype: "json",
                            datafields: [
                                { name: 'id', type: 'int' },
                                { name: 'SignatureName', type: 'string' }
                            ],
                            id: 'id',
                            localdata: data,
                            pager: function (pagenum, pagesize, oldpagenum) {
                            }
                        };
                                var dataAdapter = new $.jqx.dataAdapter(source);
                                $("#jqxgrid").jqxGrid(
                                {
                                    width: $('#jqxWidget').width(),
                                    source: dataAdapter,
                                    selectionmode: 'multiplerowsextended',
                                    sortable: true,
                                    pageable: true,
                                    autoheight: true,
                                    enabletooltips: true,
                                    columnsresize: true,
                                    //pagermode: 'simple',
                                    columns: [
                                        { text: 'Tên chữ ký', datafield: 'SignatureName' },
                                        {
                                            text: 'Xóa', datafield: 'Delete', columntype: 'button',width:100, cellsrenderer: function () {
                                                return "Xóa";
                                            }, buttonclick: function (row) {
                                                // open the popup window when the user clicks a button.
                                                id = $("#jqxgrid").jqxGrid('getrowid', row);
                                                var offset = $("#jqxgrid").offset();
                                                $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + 80, y: parseInt(offset.top) + 60 } });
                                                // show the popup window.
                                                $("#popupWindow").jqxWindow('show');
                                            }
                                        }
                                    ]
                                });

                            }
                        });
                    });
                    $("#popupWindow").jqxWindow({ width: 250, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.01 });
                    $("#del").jqxButton({ theme: theme });
                    $("#cancel").jqxButton({ theme: theme });
                    $("#del").click(function () {
                        $.ajax({
                            type: "POST",
                            url: "create-signature.aspx/Delete",
                            data: "{id:" + id + "}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                $('#jqxgrid').jqxGrid('deleterow', id);
                                $("#popupWindow").jqxWindow('hide');
                            },
                            error: function (request, status, error) {
                                alert('Chữ ký đã được gửi. Bạn không được phép xóa!');
                                $("#popupWindow").jqxWindow('hide');
                            }
                        });
                    });
                    $("#cancel").click(function () {
                        $("#popupWindow").jqxWindow('hide');
                    });
                </script>
			</div>
			</div>
 
	    </div>
    </div>    	      
</div>	        
</asp:content>





